package cn.panda.edu.service.impl;

import cn.panda.edu.dao.SelectMapper;
import cn.panda.edu.model.Select;
import cn.panda.edu.service.SelectService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 
 * 类描述：  SelectService接口的实现类
 */
@Service
public class SelectServiceImpl implements SelectService {
	
	@Resource
	private SelectMapper selectMapper;
	@Override
	public PageInfo<Select> listSelectByCourseId(Integer courseId , Integer pageIndex, Integer pageSize) {
		// TODO Auto-generated method stub
		PageHelper.startPage(pageIndex, pageSize);
		List<Select> list = selectMapper.listSelectByCourseId(courseId);
		PageInfo<Select> pageInfo = new PageInfo<>(list);
		return pageInfo;
	}

	@Override
	public PageInfo<Select> listSelectBySectionTestId(Integer sectionTestId, Integer pageIndex, Integer pageSize) {
		// TODO Auto-generated method stub
		PageHelper.startPage(pageIndex, pageSize);
		List<Select> list = selectMapper.listSelectBySectionTestId(sectionTestId);
		PageInfo<Select> pageInfo = new PageInfo<>(list);
		return pageInfo;
	}
	/**
	 * 通过ID查询选择题信息
	 */
	@Override
	public Select selectByPrimaryKey(Integer selectId) {
		// TODO Auto-generated method stub
		return selectMapper.selectByPrimaryKey(selectId);
	}
	/**
	 * 动态更新题目
	 */
	@Override
	public int updateByPrimaryKeySelective(Select record) {
		// TODO Auto-generated method stub
		return selectMapper.updateByPrimaryKeySelective(record);
	}
	/**
	 * 根据题目编号删除
	 */
	@Override
	public int deleteByPrimaryKey(Integer selectId) {
		// TODO Auto-generated method stub
		return selectMapper.deleteByPrimaryKey(selectId);
	}
	/**
	 * 动态添加题目
	 */
	@Override
	public int insertSelective(Select record) {
		// TODO Auto-generated method stub
		return selectMapper.insertSelective(record);
	}

}
